import Taro, { Component } from '@tarojs/taro'
import { View, Text } from '@tarojs/components'

import Head from './head'
import Content from './content'

import './index.scss'

class UserContent extends Component{
  publicTopic(){
    Taro.redirectTo({url: '/pages/public/index'})
  }
  render(){
    let {loginname, avatar, recent_topic, recent_replies} = this.props
    return(
      <View className='user-container'>
        <View className='user-header'>
          <Head loginname={loginname} avatar={avatar} />
        </View>
        <View className='user-content-container'>
          <Content listData={recent_topic} title='最近发布话题' />
          <Content listData={recent_replies} title='最近回复话题' />
        </View>
        <View className='public-topic'>
          <Text className='public-topic-btn' onClick={this.publicTopic.bind(this)}>发布话题</Text>
        </View>
      </View>
    )
  }
}

export default UserContent